package com.jl.magic.color;

/**
 * ΔE*ab（CIELAB）算法
 */
public class LabSimilarity implements Similarity {

    @Override
    public double distance(int[] c1, int[] c2) {
        double[] lab1 = LabUtils.rgbToLab(c1[0], c1[1], c1[2]);
        double[] lab2 = LabUtils.rgbToLab(c2[0], c2[1], c2[2]);

        double deltaL = lab1[0] - lab2[0];
        double deltaA = lab1[1] - lab2[1];
        double deltaB = lab1[2] - lab2[2];

        return Math.sqrt(deltaL * deltaL + deltaA * deltaA + deltaB * deltaB);
    }

}
